/**
  * Copyright (c) CSIRO Australia, 2009
  *
  * @author $Author: jia020 $
  * @version $Id: Util.java 643 2009-05-20 00:20:55Z jia020 $
  */
package au.csiro.nt.pdsp.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.management.timer.Timer;

/**
 * @author jia020
 *
 */
public class Util {
  public static String getDateTimeOfNow() {
      Calendar now = Calendar.getInstance();
      SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
      return formatter.format(now.getTime());
  }

  public static String getDateTimeAdd(String datetime,int daysToAdd) {
  	  SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
      Date startDate;
			try {
				startDate = formatter.parse(datetime);
	      Date endDate = new Date(startDate.getTime()+daysToAdd*Timer.ONE_DAY);
	      return formatter.format(endDate);				
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();				
				return null;
			}

  }
}
